package com.yang.spring.core.exception;

import com.yang.spring.core.exception.enums.ErrorCode;

public class SpringException extends RuntimeException {
    protected ErrorCode errorCode;

    protected String errorMsg;

    public SpringException(ErrorCode errorCode, String... args) {
        super(String.format(errorCode.getErrorMsgTemplate(), args));
        this.errorCode = errorCode;
        String errorMsgTemplate = errorCode.getErrorMsgTemplate();
        this.errorMsg = String.format(errorMsgTemplate, args);
    }

    public String getErrorMsg() {
        return this.errorMsg;
    }

    public ErrorCode getErrorCode() {
        return this.errorCode;
    }
}
